package com.ruoyi.framework.config;

import com.ruoyi.framework.config.properties.ProjectConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 全局配置类
 *
 * @author ruoyi
 */
@Component
public class RuoYiConfig {

    private static ProjectConfigProperties ruoYiConfigProperties;

    @Autowired
    private ProjectConfigProperties ruoYiConfigPropertiesTemp;

    @PostConstruct
    public void init() {
        RuoYiConfig.ruoYiConfigProperties = ruoYiConfigPropertiesTemp;
    }

    public static String getLogoText() {
        return ruoYiConfigProperties.getLogoText();
    }

    public static String getWebsiteTitle() {
        return ruoYiConfigProperties.getWebsiteTitle();
    }

    public static String getProjectName() {
        return ruoYiConfigProperties.getName();
    }


    public static String getProjectVersion() {
        return ruoYiConfigProperties.getVersion();
    }

    public static String getCopyrightYear() {
        return ruoYiConfigProperties.getCopyrightYear();
    }

    public static int getPasswordMaxRetryCount() {
        return ruoYiConfigProperties.getPasswordMaxRetryCount();
    }

    public static boolean isDemoEnabled() {
        return ruoYiConfigProperties.isDemoEnabled();
    }

    public static String getProfile() {
        return ruoYiConfigProperties.getProfile();
    }

    public static boolean isAddressEnabled() {
        return ruoYiConfigProperties.isAddressEnabled();
    }

    /**
     * 获取导入上传路径
     */
    public static String getImportPath() {
        return getProfile() + "/import";
    }

    /**
     * 获取头像上传路径
     */
    public static String getAvatarPath() {
        return getProfile() + "/avatar";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath() {
        return getProfile() + "/download/";
    }

    /**
     * 获取上传路径
     */
    public static String getUploadPath() {
        return getProfile() + "/upload";
    }
}
